﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Db;
using System.Data;
using Framework.Kit;

namespace BLL.Service
{
    /// <summary>
    /// 标的服务
    /// </summary>
    public class targetService : DbBase
    {
        /// <summary>
        /// 获取标的列表
        /// </summary>
        /// <param name="auction_no">拍卖会编号</param>
        /// <returns></returns>
        public DataTable GetTargetList(string auction_no)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                sql.Append("select e.*,auc.auctioneer_name");
                sql.Append(" from (select b.*,att.attachment_path");
                sql.Append(" from");
                sql.Append(" (select p.product_no,p.product_name,p.attachment_id,p.measurement,p.auction_mete,a.auctioneer_code,a.target_no,a.target_name,a.auction_no,a.status");
                sql.Append(" from (select t.product_no,t.auctioneer_code,t.target_no,t.target_name,t.auction_no,t.status");
                sql.Append(" from target t");
                sql.Append(" where t.auction_no = '" + auction_no + "') a");
                sql.Append(" join product p");
                sql.Append(" on p.product_no = a.product_no AND p.DEL_FLG='0'");
                sql.Append(" ) b");
                sql.Append(" left join attachment att");
                sql.Append(" on att.attachment_id = b.attachment_id) e");
                sql.Append(" left join auctioneer auc");
                sql.Append(" on e.auctioneer_code = auc.auctioneer_code");

                return queryDtSQL(sql.ToString());
            }
            catch (Exception ex)
            {
                other.WriteErrLog("根据拍卖会获取标的列表", ex);
                return null;
            }
        }
    }
}
